package com.wangge.erase;

public class MyNode extends Node<Integer> {
  
  public MyNode(Integer str) {
    super(str);
  }
  
  public void setT(Integer i) {
    System.out.println("子类设置T");
    super.setT(i);
  }
  
  public static void main(String[] args) {
    Node<String> myNode = new Node<>("20");
    Node<String> myNode1 = new Node<>("20");
    System.out.println(myNode.hashCode());
    System.out.println(myNode1.hashCode());
    // String i =(String)node.str;
  }
}

class Node<T> {
  public T str;
  
  public Node(T str) {
    this.str = str;
  }
  
  @Override
  public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = prime * result + ((str == null) ? 0 : str.hashCode());
    return result;
  }
  
  @Override
  public boolean equals(Object obj) {
    if (this == obj)
      return true;
    if (obj == null)
      return false;
    if (getClass() != obj.getClass())
      return false;
    Node other = (Node) obj;
    if (str == null) {
      if (other.str != null)
        return false;
    } else if (!str.equals(other.str))
      return false;
    return true;
  }
  
  public void setT(T t) {
    System.out.println("主类设置T");
    this.str = t;
  }
}